// TOWN SPECIAL ENCOUNTERS
//    Town 77: Lower Pit of the Wyrm

beginzonescript;

variables;

short im_hostile = 0;
short max_crime = 200;
short last_abil;
short counter = 0;
short set_ter = 0;
short set_ter2 = 0;
short i,j;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

//	set_name(,);
//	add_range_to_group(,,groupn);

	if (gf(77,21) > 0) {
		erase_char(7723);
		erase_char(7724);
		}
	
	set_name(7723,"Corrupted Dervish");
	set_coloradj(7723,2);
	set_name(7724,"Corrupted Archer");
	set_coloradj(7724,2);
	
	set_crime_tolerance(max_crime);

	break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
	if ((gf(77,15) > 0) && (set_ter == 0)) {
		set_ter = 1;
		set_terrain(0,38,48,0);
		}
	if ((gf(77,17) > 0) && (set_ter2 == 0)) {
		set_ter2 = 1;
		set_terrain(0,22,52,0);
		set_terrain(0,30,37,0);
		set_terrain(0,16,37,0);
		}
		
	if (gf(77,19) > 0) {
		sf(77,19,0);
		i = 23;
		while (i <= 30) {
			j = 50;
			while (j <= 54) {
				if (get_ran(1,0,100) < 50)
					set_floor(0,i,j,116);
					else set_floor(0,i,j,117);
				j = j + 1;
				}
			i = i + 1;
			}
		}
	
	i = 0;
	if (char_ok(get_pc_id(0))) {
		if (get_floor(0,char_loc_x(get_pc_id(0)),char_loc_y(get_pc_id(0))) == 116) 
			i = 1;
		}
	if (char_ok(get_pc_id(1))) {
		if (get_floor(0,char_loc_x(get_pc_id(1)),char_loc_y(get_pc_id(1))) == 116) 
			i = 1;
		}
	if (char_ok(get_pc_id(2))) {
		if (get_floor(0,char_loc_x(get_pc_id(2)),char_loc_y(get_pc_id(2))) == 116) 
			i = 1;
		}
	if (char_ok(get_pc_id(3))) {
		if (get_floor(0,char_loc_x(get_pc_id(3)),char_loc_y(get_pc_id(3))) == 116) 
			i = 1;
		}
	if (i > 0) {
		print_str_color("You step on a gray stone tile. There is a click.",2);
		print_str_color("Then you are elsewhere.",2);
		if (gf(77,18) > 0) {
			spawn_creature(7735);
			play_sound(189);
			set_summon_level(7735,1);
			teleport_party(24,48,1);
			}
			else {
				play_sound(189);
				spawn_creature(7736);
				set_summon_level(7736,1);				
				teleport_party(37,48,1);
				}
				
		if (gf(77,20) == 0) {
			sf(77,20,1);
			ok_dlog(22,3);
			}
		}
			
break;

beginstate 10;
	if (gf(77,18) == 0) {
		run_game_hardcode(1014);
		sf(77,18,1);
		sf(77,19,1);
		}
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

beginstate 14;
break;

//	print_str("");
//	set_terrain_string_range("",1);
//	set_terrain_string_range("The sign says - .",1);

